<template>
    <!-- 维护作业-分保参数维护页面 -->
    <div class="fillcontain">
        <el-form :model="searchParams" :rules="rules" ref="ruleForm" label-width="100px" class="search_container">
            <el-row>
                <el-col :span="6" class="common-box">
                    <el-col :span="8" class="common-lab">
                        <label class="labelName">分保代号</label>
                    </el-col>
                    <el-col :span="16">
                        <el-input clearable v-model="searchParams.acctype" placeholder=""></el-input>
                    </el-col>
                </el-col>
                <el-col :span="6" class="text_center">
                    <el-button type="primary" icon="el-icon-search" @click="subGetList"></el-button>
                    <el-button type="primary" plain icon="el-icon-refresh" @click="resetSearch"></el-button>
                </el-col>
            </el-row>
        </el-form>
        <div class="contain">
            <el-row class="bgfff pb15">
                <el-col :span="24" class="pt5">
                    <el-button type="danger" plain @click="goAdd">新增</el-button>
                </el-col>
            </el-row>
            <!-- 查询结果 -->
            <div class="table_container">
                <el-table v-loading="loading" :data=" relationtableData" highlight-current-row header-cell-class-name="table-header-class"
                    @row-click="fatherClick" style="width:100%">
                    <el-table-column min-width="120" property="acctype" label="分保代号" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column property="opera01" label="操作符" align='center' show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span>{{transformOpera(scope.row.opera01)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column property="cmin" label="最小保额" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column property="opera02" label="操作符" align='center' show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span>{{transformOpera(scope.row.opera02)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column property="cmax" label="最大保额" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column property="opera03" label="操作符" align='center' show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span>{{transformOpera(scope.row.opera03)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column property="zlinstprem" label="加费值" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column property="srpisno" label="需求号码" align='center' show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column property="update_ind" label="更新方式" align='center' show-overflow-tooltip>
                        <template slot-scope="scope">
                            <span>{{transforUpdate(scope.row.update_ind)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column min-width="120" fixed="right" label="操作" align='center'>
                        <template slot-scope="scope">
                            <!-- <el-button type="text" size="small" @click.stop="relationUpdateGo(scope.row)">修改</el-button> -->
                            <span class="operationIcon" @click.stop="relationUpdateGo(scope.row)">
                              <el-tooltip class="item" effect="light" content="修改" placement="top">
                                <i class="el-icon-edit"></i>
                              </el-tooltip>
                          </span>
                            <!--<el-button type="text" size="small" @click.stop="deleteFather(scope.row)">删除</el-button> -->
                            <span class="operationIcon ml5" @click.stop="deleteFather(scope.row)">
                                <el-tooltip class="item" effect="light" content="删除" placement="top">
                                  <i class="el-icon-delete"></i>
                                </el-tooltip>
                            </span>
                            <!--<el-button type="text" size="small">读档</el-button>-->
                        </template>
                    </el-table-column>
                </el-table>
                <el-row>
                    <el-col :span="24">
                        <div class="pagination">
                            <el-pagination background v-if='paginations.total > 0' :page-sizes="paginations.pageSizes" :page-size="paginations.pageSize"
                                :layout="paginations.layout" :total="paginations.total" :current-page='paginations.pageIndex'
                                @current-change='handleCurrentChange' @size-change='handleSizeChange'>
                            </el-pagination>
                        </div>
                    </el-col>
                </el-row>
            </div>
        </div>
        <!-- 弹框 主表修改-->
        <el-dialog :title="title_O" :visible.sync="relationDialog" width="60%" center>
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="分保代号" prop="acctype">
                            <el-input maxlength="2" v-model="form.acctype"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="操作符">
                            <el-select v-model="form.opera01" placeholder="">
                                <el-option v-for="item in operaOption1" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>


                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="最小保额" prop="cmin">
                            <el-input maxlength="10" v-model="form.cmin"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="操作符">
                            <el-select v-model="form.opera02" placeholder="">
                                <el-option v-for="item in operaOption2" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="最大保额" prop="cmax">
                            <el-input maxlength="10" v-model="form.cmax"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="操作符">
                            <el-select v-model="form.opera03" placeholder="">
                                <el-option v-for="item in operaOption1" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="加费值" prop="zlinstprem">
                            <el-input maxlength="9" v-model="form.zlinstprem"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="需求号码">
                            <el-input maxlength="10" v-model="form.srpisno"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="更新方式">
                            <el-select v-model="form.update_ind" placeholder="">
                                <el-option v-for="item in updateOption" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="save" class="Defaultbutton">保 存</el-button>
                <el-button @click="relationDialog = false">返 回</el-button>
            </span>
        </el-dialog>


        <div class="contain" v-show="currentAcctype">
            <el-row class="bgfff pb15">
                <el-col :span="24" class="pt5">
                    <el-button type="danger" plain @click="goAddChild">新增</el-button>
                </el-col>
            </el-row>
            <div class="table_container">
                <el-table :data="childData" style="width: 100%">
                    <el-table-column prop="crtable" label="险种代号" width="180">
                    </el-table-column>
                    <el-table-column prop="agcomrt01" label="保额百分比1" width="180">
                    </el-table-column>
                    <el-table-column prop="agcomrt02" label="保额百分比2">
                    </el-table-column>
                    <el-table-column prop="flag01" label="备注1" width="180">
                    </el-table-column>
                    <el-table-column prop="flag02" label="备注2" width="180">
                    </el-table-column>
                    <el-table-column min-width="120" fixed="right" label="操作" align='center'>
                        <template slot-scope="scope">
                            <!-- <el-button type="text" size="small" @click="goUpdateChild(scope.row)">修改</el-button> -->
                            <span class="operationIcon" @click="goUpdateChild(scope.row)">
                              <el-tooltip class="item" effect="light" content="修改" placement="top">
                                <i class="el-icon-edit"></i>
                              </el-tooltip>
                          </span>
                            <!-- <el-button type="text" size="small" @click="deleteChild(scope.row)">删除</el-button> -->
                            <span class="operationIcon ml5" @click="deleteChild(scope.row)">
                                <el-tooltip class="item" effect="light" content="删除" placement="top">
                                  <i class="el-icon-delete"></i>
                                </el-tooltip>
                            </span>
                            <!--<el-button type="text" size="small">读档</el-button>-->
                        </template>
                    </el-table-column>
                </el-table>
                <el-row>
                    <el-col :span="24">
                        <div class="pagination">
                            <el-pagination background v-if='paginations_child.total > 0' :page-sizes="paginations_child.pageSizes" :page-size="paginations_child.pageSize"
                                :layout="paginations_child.layout" :total="paginations_child.total" :current-page='paginations_child.pageIndex'
                                @current-change='handleCurrentChange_child' @size-change='handleSizeChange_child'>
                            </el-pagination>
                        </div>
                    </el-col>
                </el-row>
            </div>
        </div>



        <!-- 弹框 子表修改-->
        <el-dialog v-if="childDialog" :title="title_I" :visible.sync="childDialog" width="60%" center>
            <el-form ref="childForm" :model="childForm" :rules="childRules" label-width="120px">
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="险种代号" prop="crtable">
                            <el-select v-model="childForm.crtable" placeholder="">
                                <el-option v-for="(item,index) in reinsureCrtableOption" :key="index" :label="item.crtable" :value="item.crtable"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="保额百分比1" prop="agcomrt01">
                            <el-input maxlength="6" v-model="childForm.agcomrt01"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="保额百分比2" prop="agcomrt02">
                            <el-input maxlength="6" v-model="childForm.agcomrt02"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="备注1">
                            <el-input maxlength="1" v-model="childForm.flag01"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12" class="common-box">
                        <el-form-item label="备注2">
                            <el-input maxlength="1" v-model="childForm.flag02"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="saveChild" class="Defaultbutton">保 存</el-button>
                <el-button @click="childDialog = false">返 回</el-button>
            </span>
        </el-dialog>

    </div>
</template>

<script>
    import { mapState, mapGetters } from 'vuex'
    import constant from '@/utils/constant';
    import { queryListForFather, queryListForChild, addChild, updateChild, deleteChild, queryReinsureCrtable, deleteFather } from '@/api/setting/maintain/parametMaintenance.js';
    import request from '@/utils/axios';
    import appName from "@/api/appName";
    import validRules from "@/utils/validRules";
    export default {
        data() {
            var validateIsNumber = (rule, value, callback) => {
                if (isNaN(value)) {
                    callback(new Error('必须为数字'));
                } else {
                    callback();
                }
            };
            var validatePercent1 = (rule, value, callback) => {
                if (isNaN(value) || value < 0 || value > 999.99) {
                    callback(new Error('保额百分比1必须为小于999.99的数字'));
                } else {
                    callback();
                }
            };
            var validatePercent2 = (rule, value, callback) => {
                if (isNaN(value) || value < 0 || value > 999.99) {
                    callback(new Error('保额百分比2必须为小于999.99的数字'));
                } else {
                    callback();
                }
            };
            return {
                relationDialog: false,//默认隐藏 保额累计关系维护修改弹框
                // 查询条件

                rules: {
                    acctype: [
                        { required: true, message: '请输入分保代号', trigger: 'blur' },
                        { validator: validRules.isNumberorLetter, message: '请正确输入分保代号', trigger: 'blur' }
                    ],
                    cmin: [
                        { required: true, message: '必须为数字', trigger: 'blur' },
                        { validator: validateIsNumber, trigger: 'blur' }
                    ],
                    cmax: [
                        { required: true, message: '必须为数字', trigger: 'blur' },
                        { validator: validateIsNumber, trigger: 'blur' }
                    ],
                    zlinstprem: [
                        { required: true, message: '必须为数字', trigger: 'blur' },
                        { validator: validateIsNumber, trigger: 'blur' }
                    ]
                },

                childRules: {
                    crtable: [
                        { required: true, message: '请输入险种代号', trigger: 'blur' }
                    ],
                    agcomrt01: [
                        { required: true, message: '请输入百分比1', trigger: 'blur' },
                        { validator: validatePercent1, trigger: 'blur' }
                    ],
                    agcomrt02: [
                        { required: true, message: '请输入百分比2', trigger: 'blur' },
                        { validator: validatePercent2, trigger: 'blur' }
                    ]
                },
                searchParams: {
                    customerNo: '',
                    customerName: '',
                    idNo: '',
                },
                relationtableData: [//数据
                ],
                loading: false,
                title_O: '分保参数维护',
                title_I: '分保参数子表维护',
                form: {
                    acctype: '',
                    opera01: '',
                    opera02: '',
                    opera03: '',
                    cmin: '',
                    cmax: '',
                    zlinstprem: '',
                    srpisno: '',
                    update_ind: '',
                    acctype_old: '',
                    opera01_old: '',
                    opera02_old: '',
                    opera03_old: '',
                    cmin_old: '',
                    cmax_old: '',
                    zlinstprem_old: ''
                },
                option: '',
                options: [
                    { value: '1', label: '测试1' },
                    { value: '2', label: '测试2' }
                ],

                //需要给分页组件传的信息
                paginations: {
                    total: 0,        // 总数
                    pageIndex: 1,  // 当前位于哪页
                    pageSize: 10,   // 1页显示多少条
                    pageSizes: [5, 10, 15, 20],  //每页显示多少条
                    layout: "total, sizes, prev, pager, next, jumper"   // 翻页属性
                },
                paginations_child: {
                    total: 0,        // 总数
                    pageIndex: 1,  // 当前位于哪页
                    pageSize: 10,   // 1页显示多少条
                    pageSizes: [5, 10, 15, 20],  //每页显示多少条
                    layout: "total, sizes, prev, pager, next, jumper"   // 翻页属性
                },
                pickerOptions1: {
                    disabledDate(time) {
                        return time.getTime() > Date.now();
                    }
                },
                status: "add",
                currentAcctype: '',
                childData: [],
                childForm: {
                    acctype: '',
                    crtable: '',
                    flag01: '',
                    flag02: '',
                    agcomrt01: '',
                    agcomrt02: '',
                    crtable_old: ''
                },
                childDialog: false,
                childStatus: "add",
                operaOption1: [
                    {
                        value: "",
                        label: "请选择"
                    },
                    {
                        value: '1',
                        label: '>'
                    },
                    {
                        value: '2',
                        label: ">="
                    }
                ],
                operaOption2: [
                    {
                        value: "",
                        label: "请选择"
                    },
                    {
                        value: '3',
                        label: '<'
                    },
                    {
                        value: '4',
                        label: "<="
                    }
                ],
                reinsureCrtableOption: [],
                updateOption: [
                    {
                        value: "",
                        label: "请选择"
                    },
                    {
                        value: 'I',
                        label: '新增'
                    },
                    {
                        value: 'U',
                        label: "更新"
                    },
                    {
                        value: 'D',
                        label: "删除"
                    }
                ]
            }
        },
        created() {
            //          this.getList();
            this.queryReinsureCrtable();
        },
        mounted() {
            // this.getList();
        },
        methods: {
            queryReinsureCrtable() {
                this.$store.dispatch('loading/CHANGE_LOADING', true)
                queryReinsureCrtable().then(res => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false)
                    if (res.resultCode == constant.SUCCESS) {
                        this.reinsureCrtableOption = res.data;
                    }

                }).catch(err => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false);
                })
            },
            transformOpera(opera) {
                if (opera == 1) {
                    return '>'
                }
                if (opera == 2) {
                    return '>='
                }
                if (opera == 3) {
                    return '<'
                }
                if (opera == 4) {
                    return '<='
                }
                return;
            },
            transforUpdate(value) {
                if (value == 'I') {
                    return '新增'
                }
                if (value == 'U') {
                    return '更新'
                }
                if (value == 'D') {
                    return '删除'
                }
                return;
            },
            goUpdateChild(row) {
                this.childForm.acctype = row.acctype;
                this.childForm.crtable = row.crtable;
                this.childForm.crtable_old = row.crtable;
                this.childForm.flag01 = row.flag01;
                this.childForm.flag02 = row.flag02;
                this.childForm.agcomrt01 = row.agcomrt01;
                this.childForm.agcomrt02 = row.agcomrt02;
                this.childDialog = true;
                this.childStatus = "update";
                this.title_I = "分保参数维护子表修改";
            },
            save() {
                this.$refs['form'].validate((valid) => {
                    if (valid) {
                        if (this.form.cmin > 0 && this.form.opera01 == '') {
                            this.$message({
                                message: '最小保额有值，必须输入操作符',
                                type: 'error'
                            });
                            return
                        }
                        if (this.form.cmax > 0 && this.form.opera02 == '') {
                            this.$message({
                                message: '最大保额有值，必须输入操作符',
                                type: 'error'
                            });
                            return
                        }
                        if (this.form.zlinstprem > 0 && this.form.opera03 == '') {
                            this.$message({
                                message: '加费值有值，必须输入操作符',
                                type: 'error'
                            });
                            return
                        }
                        if (this.form.cmax > 0 && this.form.cmin == 0) {
                            this.$message({
                                message: '如果有输入最大保额，则一定要输入最小保额',
                                type: 'error'
                            });
                            return
                        }
                        if (this.form.cmin > 0 && this.form.cmax > 0) {
                            if (Math.round(this.form.cmin) > Math.round(this.form.cmax)) {
                                this.$message({
                                    message: '最大保额必须大于最小保额',
                                    type: 'error'
                                });
                                return
                            }
                        }
                        this.$store.dispatch('loading/CHANGE_LOADING', true)
                        if (this.status == "add") {
                            request({
                                url: appName.NB + '/maintain/reinsure/add',
                                method: 'post',
                                data: this.form
                            }).then(res => {
                                this.$store.dispatch('loading/CHANGE_LOADING', false)
                                if (res.resultCode == constant.SUCCESS) {

                                    this.relationDialog = false;
                                    this.$message({
                                        message: '新增成功',
                                        type: 'success'
                                    });
                                    this.searchParams.acctype = '';
                                    this.getList();
                                }

                            }).catch(err => {
                                this.$store.dispatch('loading/CHANGE_LOADING', false);
                            })
                        }
                        if (this.status == "update") {
                            request({
                                url: appName.NB + '/maintain/reinsure/update',
                                method: 'post',
                                data: this.form
                            }).then(res => {
                                this.$store.dispatch('loading/CHANGE_LOADING', false)
                                if (res.resultCode == constant.SUCCESS) {
                                    this.relationDialog = false;
                                    this.$message({
                                        message: '修改成功',
                                        type: 'success'
                                    });
                                    this.getList();
                                }

                            }).catch(err => {
                                this.$store.dispatch('loading/CHANGE_LOADING', false);
                            })
                        }
                    }
                })

            },
            goAdd() {
                this.status = "add";
                this.title_O = '分保参数维护新增';
                this.relationDialog = true;
                this.form.acctype = "";
                this.form.opera01 = "";
                this.form.opera02 = "";
                this.form.opera03 = "";
                this.form.cmin = "";
                this.form.cmax = "";
                this.form.zlinstprem = "";
                this.form.srpisno = "";
                this.form.update_ind = "";
            },
            relationUpdateGo(row) {
                this.status = "update";
                this.title_O = '分保参数维护修改';
                this.relationDialog = true;
                this.form.acctype = row.acctype;
                this.form.opera01 = row.opera01;
                this.form.opera02 = row.opera02;
                this.form.opera03 = row.opera03;
                this.form.cmin = row.cmin;
                this.form.cmax = row.cmax;
                this.form.zlinstprem = row.zlinstprem;
                this.form.srpisno = row.srpisno;
                this.form.update_ind = row.update_ind;


                this.form.acctype_old = row.acctype;
                this.form.opera01_old = row.opera01;
                this.form.opera02_old = row.opera02;
                this.form.opera03_old = row.opera03;
                this.form.cmin_old = row.cmin;
                this.form.cmax_old = row.cmax;
                this.form.zlinstprem_old = row.zlinstprem;
            },

            // 查询列表
            getList() {
                this.paginations.total = 0;
                this.relationtableData = [];
                this.currentAcctype = '';
                let para = {
                    pageSize: this.paginations.pageSize,
                    pageNumber: this.paginations.pageIndex,
                    acctype: this.searchParams.acctype,
                    accname: this.searchParams.accname
                }
                this.$store.dispatch('loading/CHANGE_LOADING', true)
                queryListForFather(para).then(res => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false)
                    if (res.resultCode == constant.SUCCESS && res.data && res.data.list.length) {
                        this.paginations.total = res.data.total;
                        this.relationtableData = res.data.list;
                    }

                }).catch(err => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false);
                })
            },
            // 每页多少条切换
            handleSizeChange(pageSize) {
                this.paginations.pageSize = pageSize;
                this.getList();
            },
            // 上下分页
            handleCurrentChange(page) {
                this.paginations.pageIndex = page;
                this.getList();
            },
            // 每页多少条切换
            handleSizeChange_child(pageSize) {
                this.paginations_child.pageSize = pageSize;
                this.getChildList();
            },
            // 上下分页
            handleCurrentChange_child(page) {
                this.paginations_child.pageIndex = page;
                this.getChildList();
            },
            // 根据条件查询列表
            subGetList() {
                this.paginations.pageIndex = 1;
                this.getList();
            },
            // 清除查询条件
            resetSearch() {
                this.searchParams.acctype = '';
            },
            fatherClick(row) {
                console.log(row);
                this.currentAcctype = row.acctype;
                this.getChildList();
            },



            // 查询列表
            getChildList() {
                this.paginations_child.total = 0;
                this.childData = [];
                let para = {
                    acctype: this.currentAcctype,
                    pageSize: this.paginations_child.pageSize,
                    pageNumber: this.paginations_child.pageIndex
                }
                this.$store.dispatch('loading/CHANGE_LOADING', true)
                queryListForChild(para).then(res => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false)
                    if (res.resultCode == constant.SUCCESS && res.data && res.data.list.length) {
                        this.paginations_child.total = res.data.total;
                        this.childData = res.data.list;
                    }

                }).catch(err => {
                    this.$store.dispatch('loading/CHANGE_LOADING', false);
                })
            },
            goAddChild() {
                this.childDialog = true;
                this.childStatus = "add";
                this.title_I = "分保参数维护子表新增";
                this.childForm.acctype = this.currentAcctype;
                this.childForm.crtable = '';
                this.childForm.crtable_old = '';
                this.childForm.flag01 = '';
                this.childForm.flag02 = '';
                this.childForm.agcomrt01 = '';
                this.childForm.agcomrt02 = '';
            },
            saveChild() {
                console.log(this.childForm)
                this.$refs['childForm'].validate((valid) => {
                    if (valid) {
                        this.$store.dispatch('loading/CHANGE_LOADING', true)
                        if (this.childStatus == 'add') {

                            addChild(this.childForm).then(res => {
                                this.$store.dispatch('loading/CHANGE_LOADING', false)
                                if (res.resultCode == constant.SUCCESS) {

                                    this.childDialog = false;
                                    this.$message({
                                        message: '新增成功',
                                        type: 'success'
                                    });
                                    this.getChildList();
                                }

                            }).catch(err => {
                                this.$store.dispatch('loading/CHANGE_LOADING', false);
                            })
                        } else if (this.childStatus == 'update') {
                            updateChild(this.childForm).then(res => {
                                this.$store.dispatch('loading/CHANGE_LOADING', false)
                                if (res.resultCode == constant.SUCCESS) {
                                    this.childDialog = false;
                                    this.$message({
                                        message: '修改成功',
                                        type: 'success'
                                    });
                                    this.getChildList();
                                }

                            }).catch(err => {
                                this.$store.dispatch('loading/CHANGE_LOADING', false);
                            })
                        }
                    }
                })

            },
            deleteFather(row) {

                this.$confirm("请注意，分保代号" + row.acctype + "如果只有一条记录,其下的全部子目录都将删除！", '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {

                    this.$store.dispatch('loading/CHANGE_LOADING', true)
                    deleteFather(row).then(res => {
                        this.$store.dispatch('loading/CHANGE_LOADING', false)
                        if (res.resultCode == constant.SUCCESS) {
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                            this.getList();
                        }

                    }).catch(err => {
                        this.$store.dispatch('loading/CHANGE_LOADING', false);
                    })
                })

            },
            deleteChild(row) {

                this.$confirm('确认删除?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {

                    this.$store.dispatch('loading/CHANGE_LOADING', true)
                    deleteChild(row).then(res => {
                        this.$store.dispatch('loading/CHANGE_LOADING', false)
                        if (res.resultCode == constant.SUCCESS) {
                            this.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                            this.getChildList();
                        }

                    }).catch(err => {
                        this.$store.dispatch('loading/CHANGE_LOADING', false);
                    })
                })

            }
        },
        computed: {
            ...mapGetters(['tags']),
            reload() {
                return this.$store.state.loading.reload;
            }
        },
        activated() {
            if (this.reload) {
                this.$store.dispatch('loading/CHNAGE_RELOAD', false)
                Object.assign(this.$data, this.$options.data());
            }
            document.onkeydown = (event)=>{
                  var e = event || window.event || arguments.callee.caller.arguments[0];
                  if (e && e.keyCode == 113) {
                      this.getList();
                  }
              };
        }
    }

</script>

<style lang="less" scoped>
    .fillcontain {
        padding-bottom: 0;
    }

    .contain {
        background: #fff;
        padding: 10px;
        margin-bottom: 20px;
    }

    .pagination {
        padding: 10px 20px;
        text-align: right;
    }

    .operationIcon {
        // padding: 12px;
        border: 1px solid #e5e5e5;
        border-radius: 50%;
        width: 22px;
        height: 22px;
        display: inline-block;
        cursor: pointer;
        box-shadow: 0 0 3px #f9f9f9;
    }

    .search_container {
        padding: 20px 20px 0 20px; //    border-top: 1px solid #e1e1e1;
    }

    .common-box {
        padding-bottom: 15px;
    }

    .common-lab {
        line-height: normal!important;
        text-align: right;
        .labelName {
            text-align: right;
        }
    }
</style>